/*
 * drv_ht1621.h
 *
 *  Created on: Jan 3, 2025
 *      Author: buquan_chen
 */

#ifndef APP_DRV_DRV_HT1621_H_
#define APP_DRV_DRV_HT1621_H_

/* Includes ------------------------------------------------------------------*/
#include "hal_gpio.h"

/* Define --------------------------------------------------------------------*/

#define SYSEN  0x01
#define RC256K 0x18
#define BIAS   0x28|0x01//选中COM为4个公共口   0x01  选择了1/3偏压
#define LCDON  0x03
#define SYSDIS 0x00
#define WDTDIS 0x05

#define HT1621_BIAS                 0x52                    // 1/3duty 4com
#define HT1621_SYS_DIS              0x00                    // 关振系统荡器和LCD偏压发生器
#define HT1621_SYS_EN               0x02                    // 打开系统振荡器
#define HT1621_LCD_OFF              0x04                    // 关闭LCD偏压
#define HT1621_LCD_ON               0x06                    // 打开LCE偏压
#define HT1621_XTAL                 0x28                    // 外部接时钟
#define HT1621_RC256                0x30                    // 内部时钟
#define HT1621_WDT_DIS              0X0A                    // 关闭看门狗
#define HT1621_TONE_ON              0x12                    // 打开声音输出
#define HT1621_TONE_OFF             0x10                    // 关闭声音输出

#define WrCmd  0x80//控制发送命令标识的宏
#define WrData 0xA0//控制发送写数据的宏

struct _HT1621_type{
    struct gpio_type *CS;   //chip select
    struct gpio_type *WR;   //write
    struct gpio_type *DATA; //data
    struct gpio_type *BK;   //backlight
};


/* Global Variables ----------------------------------------------------------*/

/* Function prototypes -------------------------------------------------------*/
extern uint8_t HT1621_Init(struct gpio_type *CS,struct gpio_type *WR,struct gpio_type *DATA,struct gpio_type *BK);
extern uint8_t HT1621_Check();
void HT1621_WriteData(u8 Addr,u8 Data);
void HT1621_WriteCmd(u8 Cmd);
void HT1621_Backlight_control(uint8_t state);
/* Private Functions----------------------------------------------------------*/

#endif /* APP_DRV_DRV_HT1621_H_ */
